/*
 *说明：用户信息表 增加/修改脚本
 *
 *@author liuxun 2012-03-06
*/

var opeForm;
var operationType;

$(function(){

	opeForm=$('#opeForm');

	$('#okBtn').click(doOk);
	$('#reloadBtn').click(refreshWin);
	$('#genReportBtnCmd').click(genReportOperation);
});

//保存按钮操作
function doOk() {

	var validateResult = opeForm.form('validate');
	
	if (!validateResult){
		showInfoWin('请正确填写信息!');
		return ;
	}
	
	var max_length = $('#max_length').val();
	var err_hint_count = $('#err_hint_count').val();
	var err_lock_count = $('#err_lock_count').val();
	
	var number_count = $('#number_count').val();
	var upper_count = $('#upper_count').val();
	var lower_count = $('#lower_count').val();
	var special_count = $('#special_count').val();
	
	var min_length = parseInt(number_count) + parseInt(upper_count) + parseInt(lower_count) + parseInt(special_count);
	if(parseInt(max_length) < parseInt(min_length)){
		showInfoWin('最大密码长度必须大于等于最小密码长度!');
		return ;
	}
	
	if(parseInt(err_lock_count) <= parseInt(err_hint_count)){
		showInfoWin('密码错误锁定次数必须大于错误提示次数!');
		return ;
	}
	
	var options = { 
		url: 'D_PWD_POLICY!doUpdateUsrPwdPolicy.do',
		type: 'post',
		success: function(data){
			showInfoWin('操作成功!');
			refreshWin();
		}
	};

	opeForm.ajaxSubmit(options);
}

//生成用户密码策略报表
function genReportOperation(){
	opeForm.attr('action', 'D_PWD_POLICY!genUsrPwdReport.do');
	opeForm.submit();
}
